import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by LENOVO on 2018/5/27.
 */
public class SanServlet extends HttpServlet {

    protected  void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        response.setCharacterEncoding("gbk");

        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("gb2312");
        String number = request.getParameter("number");
        double n=0;
        n=Double.parseDouble(number);
        out.println("<html>");
        out.println("<body>");
        out.println("输入的正数是:" + number + "<br>");
        out.println("这个数的平方根是："+Math.sqrt(n));
        out.println("</body>");
        out.println("</html>");
    }

}
